#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import yaml
from CheckLogMgr import CheckLogMgr

CONFIG_FILE = "config.yaml"

def get_config(file_name):
    """
    解析yaml
    :file_name: 配置文件名
    :returns: setting dict

    """

    if not os.path.exists(file_name):
        return {}

    with open(file_name, "r") as f:
        ins = None
        try:
            ins = yaml.load(f, Loader=yaml.FullLoader) #高版本
        except Exception as e:
            ins = yaml.load(f)
        return ins

def main():
    config = get_config(os.path.join(os.path.dirname(__file__), CONFIG_FILE))
    setting = config.get('setting')
    mgr = CheckLogMgr(setting.get('xml'), setting.get('input'))
    mgr.check_log()
    mgr.print_log(setting.get('output'))

if __name__ == '__main__':
    main()
